<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class UserLevel extends Model
{
    protected $table = 'user_level';
    //public $timestamps = false;
    // 状态
    const STATUS_YES = 1; // 启用
    const STATUS_NO = 2; // 停用

    /**
     * 自定义条件查询
     * @param $key
     * @param $value
     * @return mixed
     */
    public function findByWhere($key, $value)
    {
        return DB::table($this->table)->where($key, $value)->first();
    }

    /**
     * 获取所有数据
     * @param $limit
     * @return mixed
     */
    public function getListAsc()
    {
        return DB::table($this->table)
            ->select('id', 'level_name', 'money', 'deadline')
            ->where('status', 1)
            ->where('id', '>', 1)
            ->orderBy('money', 'asc')
            ->get();
    }
}
